package com.gph.saviorframework.security.web.controller;

import com.gph.saviorframework.OaConstants;
import com.gph.saviorframework.SaviorFrameworkException;
import com.gph.saviorframework.security.service.PositionLevelService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * 
 */
@Controller
@RequestMapping("/" + OaConstants.FRAMEWORK_REQUEST_PATH + "/positionlevel")
public class PositionLevelController {

	/** 日志输出 */
	final Logger logger = LoggerFactory.getLogger(PositionLevelController.class);

	/** 服务 */
	@Autowired
	private PositionLevelService positionLevelService;
	
	@RequestMapping(value = "/get", method = RequestMethod.GET)
	@ResponseBody
	public List<Map<String, Object>> get(HttpServletResponse response) throws SaviorFrameworkException, IOException {
		List<Map<String, Object>> res = positionLevelService.find("PL_ID","ASC",null);
		return res;
	}

	@RequestMapping(value = "/{position}/get", method = RequestMethod.GET)
	@ResponseBody
	public List<Map<String,Object>> getByPosition(@PathVariable("position") String position) throws SaviorFrameworkException, IOException {
		return positionLevelService.findByPosition(position);
	}
}
